<template>
<view>
<view class="top"><uni-search-bar class="sbg" bgColor="#FFFFFF" @confirm="so" :radius="100"></uni-search-bar>
</view><view class="top-pd"></view>
	<view class="b p10 bl ">本地动态列表</view>
	<block v-if="data.length>0">
	<block v-for="(newsitem,index2) in data" :key="index2">
	<media-item :lc="lc" :newitem="newsitem"></media-item>
	<yad v-if="index2 %8==4" mode="feed"></yad>
	</block>
	</block>
	<pagestatus v-if="status.code !=408" :status="status"
	v-on:btnclick="getdata"
	></pagestatus>
	<view v-else class="b p10 c">END<br>全部加载完毕</view>
</view>

</template>

<script>
	var __self=false;/*this的优化 */
	var  pageid=0
	import mediaItem from '../components/list_www.vue';
	import yad from '@/components/yad.vue'
	import pagestatus from '@/components/page-status.vue'
export default {
		components: {
			mediaItem,yad,pagestatus
		},
		data() {
			return {
lc:getApp().globalData.ysv8set.lc,
 data:[],status:{
loading:true,
icon:'content',
title:'页面加载中...',
desc:'长时间无反应请点重新加载',
showBtn:true,
btnText:'重新加载',
code:400
},
}
},onLoad(e) {
if(e.lc){
	getApp().globalData.ysv8set.lc=e.lc
		this.lc=getApp().globalData.ysv8set.lc
		}
pageid=0
__self=this;
this.getdata()
},onShareAppMessage() {
    return {
        title: "微友圈："+getApp().globalData.ysv8set.title2,
        content: getApp().globalData.ysv8set.description,
        path: 'pages/wyq/index',
        imageUrl: getApp().globalData.ysv8set.img
    }
},onReachBottom: function() {
if(this.status.code !=408) this.getdata()
},methods: {
	getdata(){
	uni.request({method:"GET",cloudCache:getApp().globalData.ysv8set.cloudCache,url:getApp().globalData.ysv8set.www+"wyq/index/"+pageid+".api",data:{},
	success:function(e){
	
	if(e.statusCode ==200){
__self.data=pageid==0?e.data.data:__self.data.concat(e.data.data),
__self.status={
title:'加载完成',
showBtn:false,
code:e.data.data.length<10?408:200
}
if(e.data.data.length>0)pageid=e.data.data[e.data.data.length-1]['btime'];
	}else{
__self.status={
title:'网络错误',
desc:'网络连接错误',
showBtn:true,
btnText:'重新加载',
code:400
 }
	}
if(getApp().globalData.ysv8set.lc==false && !getApp().globalData.lcbool){
getApp().globalData.lcbool=true;
uni.getLocation({
success: function (res) {
getApp().globalData.ysv8set.lc=getApp().globalData.ysv8set.formatLocation(res.longitude, res.latitude);  
__self.lc=getApp().globalData.ysv8set.lc
uni.showToast({ title: '位置已更新'});
},fail:function(){
uni.redirectTo({
url: '/pagea/lcxz/lcxz?url='+encodeURIComponent('/pageb/wyq/index?')
});
}});
}
	
	},fail:function(){
__self.status={
title:'网络错误',
desc:'网络连接错误',
showBtn:true,
btnText:'重新加载',
code:400
 }
	}
	});
	
	
	},so(k){
    uni.navigateTo({url: '/pageb/s/index?q='+encodeURIComponent(k.value)});
}
	},
	}
</script>

<style>
</style>
